<?php if($pu == 'pu'):?>
    <?php foreach($data as $v):?>

        <tr>
            <td style="line-height: 40px">
                <img style="border-radius: 50%" src="/<?php echo cutUrl($v['avatar'],40,40)?>">
            </td>
            <td style="line-height: 40px"><?php echo $v['nicname'] ? $v['nicname'] : $v['username'] ?></td>
            <td style="line-height: 40px"><?php echo $v['title']?></td>
            <td style="line-height: 40px"><?php echo $v['content']?></td>
            <td style="line-height: 40px"><?php echo $v['likes']?></td>
            <td style="line-height: 40px"><?php echo $v['comments']?></td>
            <td style="line-height: 40px"><?php echo $v['views']?></td>
            <td style="line-height: 40px">

                <?php

                                    foreach($v['images'] as $key=>$val){

                $pic[$key]['alt'] = $v['title'];
                $pic[$key]['src'] = '/'.$val;
                $pic[$key]['thumb'] = '/'.cutUrl($val,200,0);

                }

                ?>

                <a href="javascript:;" class="btn btn-default btn-xs img-list" data-title="<?php echo $v['title']?>" data-pic=<?php echo json_encode($pic);?>>点击查看</a>

            </td>
            <td style="line-height: 40px"><?php echo $v['create_time']?></td>
            <td style="line-height: 40px" data-id="<?php echo $v['id']?>">
                <a href="javascript:;" class="btn btn-danger btn-xs delete">删除</a>
                <a href="javascript:;" class="btn btn-success btn-xs comment-lists">查看评论</a>

            </td>
        </tr>

    <?php endforeach;?>
<?php else:?>
    <table class="table table-hover" id="show-list">
        <tr>
            <th style="border:none;">用户头像</th>
            <th style="border:none;">用户名/昵称</th>
            <th style="border:none;">标题</th>
            <th style="border:none;">内容</th>
            <th style="border:none;">点赞数量</th>
            <th style="border:none;">评论数量</th>
            <th style="border:none;">浏览量</th>
            <th style="border:none;">图片列表</th>
            <th style="border:none;">发布时间</th>
            <th style="border:none;">操作</th>
        </tr>
        <?php if($data):?>
            <?php foreach($data as $v):?>

                <tr>
                    <td style="line-height: 40px">
                        <img style="border-radius: 50%" src="/<?php echo cutUrl($v['avatar'],40,40)?>">
                    </td>
                    <td style="line-height: 40px"><?php echo $v['nicname'] ? $v['nicname'] : $v['username'] ?></td>
                    <td style="line-height: 40px"><?php echo $v['title']?></td>
                    <td style="line-height: 40px"><?php echo $v['content']?></td>
                    <td style="line-height: 40px"><?php echo $v['likes']?></td>
                    <td style="line-height: 40px"><?php echo $v['comments']?></td>
                    <td style="line-height: 40px"><?php echo $v['views']?></td>
                    <td style="line-height: 40px">

                        <?php

                            foreach($v['images'] as $key=>$val){

                                $pic[$key]['alt'] = $v['title'];
                                $pic[$key]['src'] = '/'.$val;
                                $pic[$key]['thumb'] = '/'.cutUrl($val,200,0);

                            }

                        ?>

                        <a href="javascript:;" class="btn btn-default btn-xs img-list" data-title="<?php echo $v['title']?>" data-pic=<?php echo json_encode($pic);?>>点击查看</a>

                    </td>
                    <td style="line-height: 40px"><?php echo $v['create_time']?></td>
                    <td style="line-height: 40px" data-id="<?php echo $v['id']?>">
                        <a href="javascript:;" class="btn btn-danger btn-xs delete">删除</a>
                        <a href="javascript:;" class="btn btn-success btn-xs comment-lists">查看评论</a>

                    </td>
                </tr>

            <?php endforeach;?>
        <?php endif;?>
    </table>


<script>

    $(function(){

        var page = 2;

        var id = '<?php echo $activity_id?>';

        var nums = <?php echo $nums?>;

        var total = <?php echo $total?>;


        $('.img-list','#show-list').unbind('click');
        $('.img-list','#show-list').click(function(){

            var pic = $(this).data('pic');
            var title = $(this).data('title');

            var options = {

                'title' : title,
                'id'    : 1,
                'start' : 0,
                'data'  : pic,

            }
            layer.photos({
                photos: options
            });
        });

        $('.delete','#show-list').unbind('click');
        $('.delete','#show-list').click(function(){

            var _this = $(this);

            var id = $(this).parent().data('id');

            layer.msg('确定要删除吗?删除之后不可恢复!',{
                        time: 0 //不自动关闭
                        ,btn: ['删除', '取消']
                        ,yes: function(index){

                            layer.close(index);

                            $.post('<?php echo U("Admin/Activity/Index/deleteShow")?>',{'id':id},function(result){

                                showMessage(result.msg,result.code,'','',2000);

                                if(result.code == 200) {

                                    _this
                                            .parent()
                                            .parent()
                                            .fadeOut(200,function(){

                                                $(this).remove();

                                            })

                                }

                            })

                        }
                    }
            );

        });

        var $show_lists = $('#show-list').parent();
        //选项卡
        $show_lists.scroll(function(){

            if (($show_lists.height()) - ($show_lists.scrollTop()) < 20 ) {

                if(page <= Math.ceil(total / nums)){



                    var lay = layer.load();

                    $.post('<?php echo U("Admin/Activity/Index/showList")?>',{'id':id,'pu':'pu','page':page},function(result){

                        layer.close(lay);

                        if ( result ) {

                            $('tbody',$show_lists).append(result);

                        }


                    });

                    page++;

                }

            }

        });
        //查看评论
        $('.comment-lists','#show-list').unbind('click');
        $('.comment-lists','#show-list').click(function(){

            var id = $(this).parent().data('id');

            var lay = layer.load();

            $.post('<?php echo U("Admin/Activity/Index/commentLists")?>',{'id':id},function(result){

                layer.close(lay);

                if(typeof result == 'object' && result.code == 300){

                    showMessage(result.msg,result.code,'','',2000);

                    return false;

                }

                layer.open({

                    type: 1,
                    title: '秀图评论列表',
                    area: ['90%', '90%'],
                    content: result,

                });

            });



        });


//        $('. comment-lists','#show-list').unbind('click');
//        $('. comment-lists','#show-list').click(function(){
//
//            var id = $(this).parent().data('id');
//
//
//
//        })

    });

</script>


<?php endif;?>